package com.huahai.once;

import com.huahai.mapper.UserMapper;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

/**
 * 批量插入用户数据
 *
 */
//@Component
public class InsertUsersBatch {

    @Resource
    private UserMapper userMapper;

    private static final Long NUM = 1000L;

    @Scheduled(initialDelay = 5000, fixedRate = Long.MAX_VALUE)
    public void doInsertUsersBatch() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
//        for (long i = 0; i < NUM; i++) {
//            User user = new User();
//            user.setUsername("假花海");
//            user.setUserAccount("mockUser" + i);
//            user.setAvatarUrl("https://javawebprogram.oss-cn-beijing.aliyuncs.com/2bd4f3de-7b7d-42c0-a9b8-690df5c1a97f.jpg");
//            user.setGender(i % 2 == 0 ? 0 : 1);
//            user.setUserPassword("12345678");
//            user.setPhone("123");
//            user.setEmail("123@qq.com");
//            user.setUserStatus(0);
//            user.setIsDelete(0);
//            user.setUserRole(0);
//            user.setPlanetCode("1234");
//            user.setTags("[]");
//            user.setProfile("哈哈哈");
//            userMapper.insert(user);
//        }
        stopWatch.stop();
        long totalTimeMillis = stopWatch.getTotalTimeMillis();
        System.out.println(totalTimeMillis);
    }
}
